package com.datasecops.scannerservices.service;

import com.datasecops.scannerservices.config.ConfigFilePath;
import com.datasecops.scannerservices.entity.CommonParam;
import com.datasecops.scannerservices.enumerate.DBType;
import com.datasecops.scannerservices.enumerate.EngineStatus;
import com.datasecops.scannerservices.util.ByteStreamHelper;
import com.datasecops.scannerservices.util.HttpURLHelper;

import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang3.StringUtils;
import org.dom4j.Document;
import org.dom4j.DocumentException;

import org.dom4j.DocumentHelper;
import org.dom4j.Element;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.io.*;
import java.net.MalformedURLException;
import java.net.URL;
import java.net.URLConnection;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;

/**
 * 心跳服务处理
 *
 * @author: SunLingzhi
 * @time: 2022/8/16 14:48
 */
@Service
@Slf4j
public class HeartbeatServer {

    //宿主IP
    @Value("${host.address}")
    private String hostIp;

    //宿主Port
    @Value("${host.port}")
    private Integer hostPort;

    @Resource
    private ScanProcessServer scanProcessServer;

    @Resource
    private ShareScanProcessServer shareScanProcessServer ;

    @Resource
    private ScannerEngineServer engineServer;//新增

    /**
     * 返回参数处理
     *
     * @param
     * @return
     * @Description
     * @author SunLingzhi
     * @time 2022/8/10 17:43
     */
    public void disposeResultData(String msg) {
        Document document;
        try {
            document = DocumentHelper.parseText(msg.trim());//解析XML形式的文本,得到document对象.
        } catch (DocumentException e) {
            log.error("Failed disposeResultData error: " + e.getMessage());
            return;
        }

        Element rootNode = document.getRootElement();//获取文档的根节点.

        //通用命令
        Element cmdResultNode = rootNode.element("CmdResult");//元素的某个指定（qualified name或者local name）的子元素,    取出CmdResult字节点
        if (null != cmdResultNode) {
            boolean isChange = Boolean.parseBoolean(cmdResultNode.attributeValue("IsChange"));//取出IsChange属性的值
            if (isChange) {//发现命令
                Element cmdListNode = cmdResultNode.element("CmdList");
                if (null != cmdListNode) {
                    List<Element> cmdNodes = cmdListNode.elements();//取出所有的子节点
                    for (Element cmdNode : cmdNodes) {
                        String des = cmdNode.attributeValue("Des");
                        String paramValue = cmdNode.attributeValue("ParamValue");

                        System.out.println(des);
                    }

                }
            }
        }

        //启动命令 todo 是否舍弃该命令
        Element scanServerNode = rootNode.element("ScanServerResult");
        if (null != scanServerNode) {
            boolean isChange = Boolean.parseBoolean(scanServerNode.attributeValue("IsChange"));
            if (isChange) {
                Element jobParam = scanServerNode.element("ScanJobParameter");
                String jobName = jobParam.attributeValue("Name");
                String taskParamPath = jobParam.attributeValue("TaskParamPath");
                String scanJobID = jobParam.attributeValue("JobID");
                String scannerID = jobParam.attributeValue("ScannerID");
                String networkSharing = jobParam.attributeValue("NetworkSharing");
                //String scannerID = "9A04D33-E373-AFD5-5551-19B93539B5D78";
                CommonParam commonParam = new CommonParam();
                StringBuilder startPullScanFingerprint = null;
                StringBuilder startPullScanDict = null;
                StringBuilder pullScanFingerprint = null;
                StringBuilder stringBuilder = null;
                //新增,测试扫描时间的问题
                String url = "http://"+hostIp+":"+ hostPort +"/EE/DlpSrvInfoToClient?Type=DlpScanTaskInfo";
                byte[] paramData = getParamData(scanJobID);
                String resultData = HttpURLHelper.connection(url, paramData);
                //解析参数
                Document documents = null;
                try {
                    documents = DocumentHelper.parseText(resultData);
                } catch (DocumentException e) {
                    log.error("Failed Method parse document error: " + e.getMessage());
                }
                Element rootElement = documents.getRootElement();
                String jobId = rootElement.attributeValue("JobID");
                //>>>>>>>>>>1、调用扫描引擎--执行开始命令 ScannerEngine.exe
                engineServer.callScannerEngine(jobId, "scanproxy", EngineStatus.START.getValue(), null);
                try {
                    //拉取策略值的相关相关信息
                    stringBuilder = startPullScanTactics(scanJobID);
                    //拉取指纹值的相关信息
                    startPullScanFingerprint = startPullScanFingerprint();
                    //拉取字典值的相关信息
                    startPullScanDict = startPullScanDict();
                    //拉取机器学习库的相关信息
                    pullScanFingerprint = SLPullScanFingerprint();
                } catch (Exception e) {
                    e.printStackTrace();
                    log.error("策略文件落盘失败,原因是:" + e.getMessage());
                }
               commonParam.setFingerPath(String.valueOf(startPullScanFingerprint));
                commonParam.setDictPath(String.valueOf(startPullScanDict));
                commonParam.setMchClusterPath(String.valueOf(pullScanFingerprint));
                commonParam.setPolicyPath(String.valueOf(stringBuilder));
                //拉取扫描数据库相关信息
                startPullScanDBParam(scanJobID,commonParam,jobName,scannerID,networkSharing);
            }
        }
    }


    /**
     * 拉取扫描数据库相关信息
     *
     * @param
     * @param commonParam
     * @param jobName
     * @param scannerID
     * @param networkSharing
     * @return
     * @Description
     * @author SunLingzhi
     * @time 2022/8/17 17:01
     */
    private void startPullScanDBParam(String scanJobId, CommonParam commonParam, String jobName, String scannerID,
                                      String networkSharing) {
        if (networkSharing == null){
            networkSharing = "DB";
        }
        if (StringUtils.isBlank(hostIp)){
            log.error("Failed method startPullScanDBParam param is empty hostIp:" + hostIp + " &hostPort:" + hostPort);
            return;
        }

        String url = "http://"+hostIp+":"+ hostPort +"/EE/DlpSrvInfoToClient?Type=DlpScanTaskInfo";
        byte[] paramData = getParamData(scanJobId);
        String resultData = HttpURLHelper.connection(url, paramData);
        if (null == resultData) {
            log.error("Failed Method PullScanDBParam error: " + url);
            return;
        }
        //解析参数
        Document document = null;
        try {
            document = DocumentHelper.parseText(resultData);
        } catch (DocumentException e) {
            log.error("Failed Method parse document error: " + e.getMessage());
        }
        if (null == document) {
            return;
        }
        //new ScanProcessServer().startScanProcess(document);//调试
        //开始扫描流程
        if (networkSharing.equalsIgnoreCase(DBType.FILESERVER.name())){
            shareScanProcessServer.startShareScanProcess(document,commonParam,scanJobId,jobName,scannerID);
        }else {
            scanProcessServer.startScanProcess(document,commonParam,scanJobId,jobName,scannerID);
        }



    }


      /**
       *拉取扫描数据库字典相关信息(测试)
       * @Description
       * @author GeXiaoLong
       * @time 2023/2/22 20:15
       * @param
       * @return void
       */
    private StringBuilder startPullScanDict() {
        if (StringUtils.isBlank(hostIp)) {
            log.error("Failed method startPullScanDict param is empty hostIp:" + hostIp + " &hostPort:" + hostPort);
            return null;
        }

        String url = "http://" + hostIp + ":" + hostPort + "/EE/DlpSrvInfoToClient?Type=DlpSystemFileDownloadPath";
        byte[] paramData = getDictParamData();
        String resultData = HttpURLHelper.connection(url, paramData);
        if (null == resultData) {
            log.error("Failed Method PullScanDict error: " + url);
            return null;
        }

        String[] split = resultData.split("FirstUrlAddress=");
        List<String> strList = new ArrayList<>(Arrays.asList(split));
        if (strList.size() <= 0){
            log.error("Method startPullScanDict Array is empty");
            return null;
        }

        String tableName = strList.get(1);
        String substring = tableName.substring(1, tableName.length() - 3);

        StringBuilder stringBuilder = null;
        try {
            String filename = ConfigFilePath.getScannerDictionaries();
            stringBuilder = diskDictionaryValue(substring, filename);
        } catch (IOException e) {
            e.printStackTrace();
        }

        return stringBuilder;
    }

     /**
      *拉取扫描数据库策略相关信息
      * @Description
      * @author GeXiaoLong
      * @time 2023/2/25 17:16
      * @param
      * @param scanJobID
      * @return
      */
    private StringBuilder startPullScanTactics(String scanJobID) {
        if (StringUtils.isBlank(hostIp)) {
            log.error("Failed method startPullScanDict param is empty hostIp:" + hostIp + " &hostPort:" + hostPort);
            return null;
        }

        String url = "http://" + hostIp + ":" + hostPort + "/EE/DlpSrvInfoToClient?Type=DlpScannerGetPolicySet";
        byte[] paramData = getTacticsParamData(scanJobID);
        String resultData = HttpURLHelper.connection(url, paramData);
        if (null == resultData) {
            log.error("Failed Method PullScanDict error: " + url);
            return null;
        }
        StringBuilder stringBuilder = null;
        try {
            String filename = ConfigFilePath.getScannerStrategy();
            stringBuilder = diskStrategyValue(resultData, filename);
        } catch (IOException e) {
            e.printStackTrace();
        }
        return stringBuilder;
    }

     /**
      *拉取扫描数据库指纹相关信息
      * @Description
      * @author GeXiaoLong
      * @time 2023/2/22 20:16
      * @param
      * @return
      */
    private StringBuilder startPullScanFingerprint() {
        if (StringUtils.isBlank(hostIp)) {
            log.error("Failed method startPullScanFingerprint param is empty hostIp:" + hostIp + " &hostPort:" + hostPort);
            return null;
        }

        String url = "http://" + hostIp + ":" + hostPort + "/EE/DlpSrvInfoToClient?Type=DlpSystemFileDownloadPath";
        byte[] paramData = getFingerprintParamData();
        String resultData = HttpURLHelper.connection(url, paramData);
        if (null == resultData) {
            log.error("Failed Method PullScanDict error: " + url);
            return null;
        }
        String[] split = resultData.split("FirstUrlAddress=");
        List<String> strList = new ArrayList<>(Arrays.asList(split));
        if (strList.size() <= 0){
            log.error("Method startPullScanFingerprint Array is empty");
            return null;
        }

        String tableName = strList.get(1);
        String substring = tableName.substring(1, tableName.length() - 3);
        StringBuilder stringBuilder = null;
        try {
            String filename = ConfigFilePath.getScannerExample();
            stringBuilder = dfingerprintDictionaryValue(substring, filename);
        } catch (IOException e) {
            e.printStackTrace();
        }
        return stringBuilder;
    }

     /**
      *拉取扫描机器学习库相关信息
      * @Description
      * @author GeXiaoLong
      * @time 2023/2/23 13:52
      * @param
      * @return
      */
    private StringBuilder SLPullScanFingerprint() {
        if (StringUtils.isBlank(hostIp)) {
            log.error("Failed method SLPullScanFingerprint param is empty hostIp:" + hostIp + " &hostPort:" + hostPort);
            return null;
        }

        String url = "http://" + hostIp + ":" + hostPort + "/EE/DlpSrvInfoToClient?Type=DlpSystemFileDownloadPath";
        byte[] paramData = getSLParamData();
        String resultData = HttpURLHelper.connection(url, paramData);
        if (null == resultData) {
            log.error("Failed Method SLPullScanFingerprint error: " + url);
            return null;
        }

        String[] split = resultData.split("FirstUrlAddress=");
        List<String> strList = new ArrayList<>(Arrays.asList(split));
        if (strList.size() <= 0){
            log.error("Method SLPullScanFingerprint Array is empty");
            return null;
        }

        String tableName = strList.get(1);
        String substring = tableName.substring(1, tableName.length() - 3);
        StringBuilder stringBuilder = null;
        try {
            String filename = ConfigFilePath.getScannerMchClusterPathDB();
            stringBuilder = diskDictionaryValue(substring, filename);
        } catch (IOException e) {
            e.printStackTrace();
        }
        return stringBuilder;
    }

   /**
    *获取url传参(字典值)
    * @Description
    * @author GeXiaoLong
    * @time 2023/2/22 20:15
    * @param
    * @return byte[]
    */
    private static byte[] getDictParamData() {
        Element rootNode = DocumentHelper.createElement("Parameters");//:创建文档并设置文档的根元素节点

        Element idNode = DocumentHelper.createElement("Parameter");
        idNode.addAttribute("name", "Type");
        idNode.addAttribute("value", "Dictionary");
        rootNode.add(idNode);

        byte[] paramData = null;
        try {
            String strParamXml = ByteStreamHelper.toXmlString(rootNode);
            paramData = ByteStreamHelper.formatParamDataFlow(strParamXml);
        } catch (IOException e) {
            e.printStackTrace();
        }
        return paramData;
    }

     /**
      *获取url传参(策略值)
      * @Description
      * @author GeXiaoLong
      * @time 2023/2/25 17:21
      * @param
      * @param scanJobID
      * @return
      */
    private static byte[] getTacticsParamData(String scanJobID) {
        Element rootNode = DocumentHelper.createElement("Parameters");//:创建文档并设置文档的根元素节点

        Element idNode = DocumentHelper.createElement("Parameter");
        idNode.addAttribute("name", "ScanTaskID");
        idNode.addAttribute("value", scanJobID);
        rootNode.add(idNode);

        byte[] paramData = null;
        try {
            String strParamXml = ByteStreamHelper.toXmlString(rootNode);
            paramData = ByteStreamHelper.formatParamDataFlow(strParamXml);
        } catch (IOException e) {
            e.printStackTrace();
        }
        return paramData;
    }


     /**
      *获取url传参(指纹值)
      * @Description
      * @author GeXiaoLong
      * @time 2023/2/22 20:19
      * @param
      * @return
      */
    private static byte[] getFingerprintParamData(){
        Element rootNode = DocumentHelper.createElement("Parameters");//:创建文档并设置文档的根元素节点

        Element idNode = DocumentHelper.createElement("Parameter");
        idNode.addAttribute("name", "Type");
        idNode.addAttribute("value", "FingerprintLibSub");
        rootNode.add(idNode);

        byte[] paramData = null;
        try {
            String strParamXml = ByteStreamHelper.toXmlString(rootNode);
            paramData = ByteStreamHelper.formatParamDataFlow(strParamXml);
        } catch (IOException e) {
            e.printStackTrace();
        }
        return paramData;
    }


     /**
      *获取url传参(机器学习库)
      * @Description
      * @author GeXiaoLong
      * @time 2023/2/23 13:55
      * @param
      * @return
      */
    private static byte[] getSLParamData(){
        Element rootNode = DocumentHelper.createElement("Parameters");//:创建文档并设置文档的根元素节点

        Element idNode = DocumentHelper.createElement("Parameter");
        idNode.addAttribute("name", "Type");
        idNode.addAttribute("value", "ClusterLib");
        rootNode.add(idNode);

        byte[] paramData = null;
        try {
            String strParamXml = ByteStreamHelper.toXmlString(rootNode);
            paramData = ByteStreamHelper.formatParamDataFlow(strParamXml);
        } catch (IOException e) {
            e.printStackTrace();
        }
        return paramData;
    }

    /**
     * 获取url传参(策略)
     *
     * @param
     * @return
     * @Description
     * @author SunLingzhi
     * @time 2022/8/17 18:01
     */
    private static byte[] getParamData(String scanJobId) {
        Element rootNode = DocumentHelper.createElement("Parameters");//:创建文档并设置文档的根元素节点

        Element idNode = DocumentHelper.createElement("Parameter");
        idNode.addAttribute("name", "ScanTaskID");
        idNode.addAttribute("value", scanJobId);
        rootNode.add(idNode);

        byte[] paramData = null;
        try {
            String strParamXml = ByteStreamHelper.toXmlString(rootNode);
            paramData = ByteStreamHelper.formatParamDataFlow(strParamXml);
        } catch (IOException e) {
            e.printStackTrace();
        }
        return paramData;
    }

     /**
      *xml文件落盘(字典库、机器学习库专用)
      * @Description
      * @author GeXiaoLong
      * @time 2023/2/22 20:24
      * @param
      * @return
      */
    public StringBuilder diskDictionaryValue(String xmlString, String filename) throws IOException {

        //基础path
        StringBuilder basicPath = new StringBuilder(ConfigFilePath.getScannerDirPath()).append(File.separator);
        basicPath.append(ConfigFilePath.getScannerResource());
        log.error("basicPath的值是:"+basicPath);
        File dir = new File(basicPath.toString());
        if (!dir.exists()){
            dir.mkdir();
        }

        basicPath.append(File.separator).append(filename);
        String fileName = String.valueOf(basicPath);
        // 利用URL类，获取指定的网址URL
        URLConnection connection = new URL(xmlString).openConnection();
        // 从URL中获取网站的连接
        InputStream is = connection.getInputStream();
        // 创建文件，将网页中指定数据写入文件
        FileOutputStream fos = new FileOutputStream(fileName);
        // 读取网页中指定数据
        int b;
        while((b=is.read()) != -1){
            fos.write(b);
        }
        fos.close();
        is.close();
        return basicPath;
    }

     /**
      *xml文件落盘(策略)
      * @Description
      * @author GeXiaoLong
      * @time 2023/2/27 11:08
      * @param
      * @return
      */
    public StringBuilder diskStrategyValue(String xmlString, String filename) throws IOException {
        //基础path
        StringBuilder basicPath = new StringBuilder(ConfigFilePath.getScannerDirPath()).append(File.separator);
        basicPath.append(ConfigFilePath.getScannerResource());

        File dir = new File(basicPath.toString());
        if (!dir.exists()){
            dir.mkdir();
        }
        basicPath.append(File.separator).append(filename);


/*        // 使用java.io.FileWriter类来写入XML文件
        FileWriter writer = new FileWriter(String.valueOf(basicPath));
        // 使用java.io.BufferedWriter类来缓冲XML文件
        BufferedWriter bufferedWriter = new BufferedWriter(writer);
        // 使用java.io.PrintWriter类来写入XML文件
        PrintWriter printWriter = new PrintWriter(bufferedWriter);
        // 写入XML文件
        printWriter.write(xmlString);
        // 关闭文件
        printWriter.close();*/


        // 使用java.io.FileOutputStream类来写入XML文件
        FileOutputStream fos = new FileOutputStream(String.valueOf(basicPath));
        // 添加BOM头
        fos.write(new byte[] {(byte)0xFF, (byte)0xFE});
        // 使用java.io.OutputStreamWriter类来编码XML文件格式
        OutputStreamWriter osw = new OutputStreamWriter(fos, "UTF-16LE");
        // 使用java.io.BufferedWriter类来缓冲XML文件
        BufferedWriter bufferedWriter = new BufferedWriter(osw);
        // 使用java.io.PrintWriter类来写入XML文件
        PrintWriter printWriter = new PrintWriter(bufferedWriter);
        // 写入XML文件
        printWriter.write(xmlString);
        // 关闭文件
        printWriter.close();



        return basicPath;
    }



     /**
      *zip文件落盘(指纹库)
      * @Description
      * @author GeXiaoLong
      * @time 2023/2/23 15:04
      * @param
      * @return
      */
    public StringBuilder dfingerprintDictionaryValue(String xmlString, String filename) throws IOException {
        //基础path
        StringBuilder basicPath = new StringBuilder(ConfigFilePath.getScannerDirPath()).append(File.separator);
        basicPath.append(ConfigFilePath.getScannerResource());

        File dir = new File(basicPath.toString());
        if (!dir.exists()){
            dir.mkdir();
        }

        basicPath.append(File.separator).append(filename);

        URL url = null;
        try {
            url = new URL(xmlString);
        } catch (MalformedURLException e) {
            e.printStackTrace();
        }
        //打开连接
        InputStream is = null;
        try {
            if (null != url){
                is = url.openStream();
            }
        } catch (IOException e) {
            e.printStackTrace();
        }

        //从输入流下载zip文件
        FileOutputStream outputStream = null;
        try {
            outputStream = new FileOutputStream(String.valueOf(basicPath));
        } catch (FileNotFoundException e) {
            e.printStackTrace();
        }

        int len;
        byte[] buffer = new byte[1024];
        try {
            while ((len = is.read(buffer)) != -1) {
                outputStream.write(buffer, 0, len);
            }
        } catch (IOException e) {
            e.printStackTrace();
        }

        // 关闭IO
        try {
            is.close();
            outputStream.close();
        } catch (IOException e) {
            e.printStackTrace();
        }
        return basicPath;
    }



    public static void main(String[] args) throws IOException {
        HeartbeatServer heartbeatServer = new HeartbeatServer();
        heartbeatServer.souls();
        StringBuilder basicPath = new StringBuilder(ConfigFilePath.getScannerDirPath() + File.separator);
        basicPath = new StringBuilder(basicPath + "fullepathsssss");
        String found = String.valueOf((basicPath));
        System.out.println(found);
        File dir = new File(found);
        dir.mkdir();
        //startScanning("11111");
       // new HeartbeatServer().startPullScanDBParam("8F46EA9D-3C2A-0916-22C2-6AC71770CADD");

    }
    //下载文件
    public void soul() throws IOException {
        String url = "http://10.26.18.61:3311/resdownload/Dictionary_39517EF5-F5E7-8FF7-A61A-5002D640F853";
        String fileName = "P:\\ScannerService\\scanner\\fullepath\\fullepath.xml";
        // 利用URL类，获取指定的网址URL
        URLConnection connection = new URL(url).openConnection();
        // 从URL中获取网站的连接
        InputStream is = connection.getInputStream();
        // 创建文件，将网页中指定数据写入文件
        FileOutputStream fos = new FileOutputStream(fileName);
        // 读取网页中指定数据
        int b;
        while((b=is.read()) != -1){
            fos.write(b);
        }
        fos.close();
        is.close();
    }
    public void souls(){
        String  ss = "<?xml version=\"1.0\" encoding=\"UTF-16\"?>\n" +
                "<DownloadInfo IsEncrypt=\"TRUE\" InfoExist=\"TRUE\" " +
                "SecondUrlAddress=\"/resdownload/Dictionary_39517EF5-F5E7-8FF7-A61A-5002D640F853\" " +
                "MD5=\"f5e1464a932c85420bf5fc50ef881c96\" Delay=\"0\" FirstUrlAddress=\"http://10.26.18" +
                ".61:3311/resdownload/Dictionary_39517EF5-F5E7-8FF7-A61A-5002D640F853\"/>";

        System.out.println(ss);
        String[] firstUrlAddresses = ss.split("FirstUrlAddress=");
        ArrayList<String> strList = new ArrayList<>(Arrays.asList(firstUrlAddresses));
        String tableName = strList.get(1);
        String substring = tableName.substring(0, tableName.length() - 2);
        System.out.println(substring);

    }

    public void soulss(){
        //获取URL
        URL url = null;
        try {
            url = new URL("http://10.26.18.61:3311/resdownload/FingerprintLibSub_BDDDB707-2BB2-CF9C-0D19" +
                    "-3287ECEFA310");
        } catch (MalformedURLException e) {
            e.printStackTrace();
        }
        //打开连接
        InputStream is = null;
        try {
            is = url.openStream();
        } catch (IOException e) {
            e.printStackTrace();
        }

        //从输入流下载zip文件
        FileOutputStream outputStream = null;
        try {
            outputStream = new FileOutputStream(new File("P:\\ScannerService\\scanner\\fullepath\\example.zip"));
        } catch (FileNotFoundException e) {
            e.printStackTrace();
        }

        int len;
        byte[] buffer = new byte[1024];
        try {
            while ((len = is.read(buffer)) != -1) {
                outputStream.write(buffer, 0, len);
            }
        } catch (IOException e) {
            e.printStackTrace();
        }

        // 关闭IO
        try {
            is.close();
            outputStream.close();
        } catch (IOException e) {
            e.printStackTrace();
        }
    }
    }


/*
            msg = "<DLP name=\"Heartbeat\">\n" +
                "\t<ConfigResult IsChange=\"FALSE\"/>\n" +
                "\t<PlyResult IsClear=\"FALSE\" IsChange=\"FALSE\"/>\n" +
                "\t<CmdResult IsChange=\"TRUE\">\n" +
                "\t\t<CmdList>\n" +
                "\t\t\t<Cmd ParamLink=\"\" Des=\"SCANNER_SERVER_PARAM\" Type=\"SCANNER_SERVER_PARAM\" ParamValue=\"&lt;?xml version=&quot;1.0&quot; encoding=&quot;UTF-16&quot;?&gt;\n" +
                "&lt;ScanJobParameter Name=&quot;~~~~~~扫描服务~~~~~~&quot; Cmd=&quot;Start&quot; JobID=&quot;422DB4E6-DA7B-4BBA-46BD-476612DF0469&quot;ScannerID=&quot;33FF8521-7531-6CD8-9D17-AD7DECDE6D3A&quot; DstType=&quot;SQLServer&quot;&gt; &lt;LastScan CompleteTime=&quot;&quot;/&gt; &lt;OcrLib Path=&quot;C:\\Program Files (x86)\\Dsm\\DSM\\bin\\ocr_res.zip&quot;/&gt; &lt;Server Ip=&quot;10.26.18.59&quot; Port=&quot;3311&quot; HttpPort=&quot;8082&quot;/&gt;&lt;/ScanJobParameter&gt;\" WithParam=\"FALSE\"/>\n" +
                "\t\t</CmdList>\n" +
                "\t</CmdResult>\n" +
                "</DLP> ";*/


